package c.j.a.d.b.e;

import android.content.Context;
import android.os.SystemClock;
import c.j.a.c.y.a.i;
import c.j.a.d.b.h.d;
import c.j.a.d.b.i.h;
import c.j.a.d.b.j.p;
import c.j.a.d.b.j.q;
import c.j.a.d.b.m.e;
import com.ss.android.socialbase.downloader.e.a;
import com.ss.android.socialbase.downloader.g.b;
import com.ss.android.socialbase.downloader.g.c;
import java.io.BufferedOutputStream;
import java.io.FileDescriptor;
import java.io.InputStream;
import java.util.concurrent.ExecutorService;

/* compiled from: DownloadResponseHandler */
public class f {
    public long A;
    public long B;
    public volatile long C = 0;
    public volatile long D = 0;
    public final c a;
    public final String b;
    public final b c;
    public final h d;
    public n e;
    public p f;
    public t g;
    public d h;
    public a i;
    public volatile boolean j;
    public volatile boolean k;
    public final e l;
    public long m;
    public long n;
    public volatile long o;
    public volatile long p;
    public final boolean q;
    public final c.j.a.d.b.l.a r;
    public final c.j.a.d.b.a.a s;
    public final boolean t;
    public final long u;
    public final long v;
    public final boolean w;
    public boolean x;
    public long y;
    public long z;

    public f(c cVar, String str, h hVar, b bVar, e eVar) {
        this.a = cVar;
        this.b = str;
        n x = b.x();
        this.e = x;
        if (x instanceof c.j.a.d.b.j.h) {
            c.j.a.d.b.j.h hVar2 = (c.j.a.d.b.j.h) x;
            this.f = hVar2.a;
            this.g = hVar2.b;
        }
        this.d = hVar;
        this.c = bVar;
        this.l = eVar;
        long q = bVar.q();
        this.m = q;
        this.n = q;
        boolean z = false;
        if (bVar.h()) {
            this.p = bVar.e;
        } else {
            this.p = bVar.g(false);
        }
        this.o = bVar.d;
        this.s = c.j.a.d.b.a.a.c.a;
        c.j.a.d.b.l.a d = c.j.a.d.b.l.a.d(cVar.g0());
        this.r = d;
        boolean z2 = d.b("sync_strategy", 0) == 1;
        this.t = z2;
        if (z2) {
            long b = (long) d.b("sync_interval_ms_bg", 1000);
            this.u = Math.max((long) d.b("sync_interval_ms_fg", 5000), 500);
            this.v = Math.max(b, 500);
        } else {
            this.u = 0;
            this.v = 0;
        }
        if (d.b("monitor_rw", 0) == 1) {
            z = true;
        }
        this.w = z;
        this.q = i.s(65536);
    }

    public final c.j.a.d.b.k.c a(InputStream inputStream) {
        int i;
        Context context = b.a;
        synchronized (b.class) {
            i = b.K;
        }
        if (this.r.b("rw_concurrent", 0) == 1) {
            c cVar = this.a;
            if (cVar.R == 1 && cVar.T > 20971520) {
                try {
                    c.j.a.d.b.k.a aVar = new c.j.a.d.b.k.a(inputStream, i, this.r.b("rw_concurrent_max_buffer_count", 4));
                    this.x = true;
                    return aVar;
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
        }
        c.j.a.d.b.k.e eVar = new c.j.a.d.b.k.e(inputStream, i);
        this.x = false;
        return eVar;
    }

    /* JADX WARNING: Removed duplicated region for block: B:59:0x0134 A:{Catch:{ all -> 0x013c }} */
    public final void b(double r20) {
        /*
        r19 = this;
        r1 = r19;
        r2 = r20;
        r0 = "setting_tag";
        r4 = r1.r;
        r5 = "monitor_download_io";
        r6 = 0;
        r4 = r4.b(r5, r6);
        if (r4 != 0) goto L_0x0012;
    L_0x0011:
        return;
    L_0x0012:
        r7 = r1.B;
        r7 = (double) r7;
        r9 = 0;
        r5 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1));
        if (r5 > 0) goto L_0x001c;
    L_0x001b:
        return;
    L_0x001c:
        r5 = r1.b;	 Catch:{ all -> 0x013c }
        r5 = android.net.Uri.parse(r5);	 Catch:{ all -> 0x013c }
        r11 = r5.getHost();	 Catch:{ all -> 0x013c }
        r12 = r5.getPath();	 Catch:{ all -> 0x013c }
        r5 = r5.getLastPathSegment();	 Catch:{ all -> 0x013c }
        r13 = android.text.TextUtils.isEmpty(r12);	 Catch:{ all -> 0x013c }
        if (r13 != 0) goto L_0x0047;
    L_0x0034:
        r13 = android.text.TextUtils.isEmpty(r5);	 Catch:{ all -> 0x013c }
        if (r13 != 0) goto L_0x0047;
    L_0x003a:
        r13 = r12.length();	 Catch:{ all -> 0x0047 }
        r14 = r5.length();	 Catch:{ all -> 0x0047 }
        r13 = r13 - r14;
        r12 = r12.substring(r6, r13);	 Catch:{ all -> 0x0047 }
    L_0x0047:
        r13 = 0;
        r14 = r1.j;	 Catch:{ all -> 0x013c }
        if (r14 == 0) goto L_0x004f;
    L_0x004c:
        r14 = r13;
        r13 = 1;
        goto L_0x006e;
    L_0x004f:
        r14 = r1.k;	 Catch:{ all -> 0x013c }
        if (r14 == 0) goto L_0x0056;
    L_0x0053:
        r14 = r13;
        r13 = 2;
        goto L_0x006e;
    L_0x0056:
        r14 = r1.i;	 Catch:{ all -> 0x013c }
        if (r14 == 0) goto L_0x006c;
    L_0x005a:
        r13 = c.j.a.d.b.e.b.a();	 Catch:{ all -> 0x013c }
        r13 = c.j.a.d.b.n.a.G(r13);	 Catch:{ all -> 0x013c }
        if (r13 != 0) goto L_0x0067;
    L_0x0064:
        r13 = 1049; // 0x419 float:1.47E-42 double:5.183E-321;
        goto L_0x0069;
    L_0x0067:
        r13 = r14.a;	 Catch:{ all -> 0x013c }
    L_0x0069:
        r14 = r14.b;	 Catch:{ all -> 0x013c }
        goto L_0x006e;
    L_0x006c:
        r14 = r13;
        r13 = 0;
    L_0x006e:
        r15 = r1.d;	 Catch:{ all -> 0x013c }
        if (r15 == 0) goto L_0x0078;
    L_0x0072:
        r15 = r15 instanceof c.j.a.d.b.i.e;	 Catch:{ all -> 0x013c }
        if (r15 == 0) goto L_0x0078;
    L_0x0076:
        r15 = 0;
        goto L_0x0079;
    L_0x0078:
        r15 = 1;
    L_0x0079:
        r6 = java.util.concurrent.TimeUnit.SECONDS;	 Catch:{ all -> 0x013c }
        r9 = 1;
        r9 = r6.toNanos(r9);	 Catch:{ all -> 0x013c }
        r9 = (double) r9;	 Catch:{ all -> 0x013c }
        r9 = r7 / r9;
        r6 = new org.json.JSONObject;	 Catch:{ all -> 0x013c }
        r6.<init>();	 Catch:{ all -> 0x013c }
        r16 = r4;
        r4 = r1.r;	 Catch:{ all -> 0x013c }
        r17 = r7;
        r7 = "";
        r4 = r4.g(r0, r7);	 Catch:{ all -> 0x013c }
        r6.put(r0, r4);	 Catch:{ all -> 0x013c }
        r0 = "url_host";
        r6.put(r0, r11);	 Catch:{ all -> 0x013c }
        r0 = "url_path";
        r6.put(r0, r12);	 Catch:{ all -> 0x013c }
        r0 = "url_file";
        r6.put(r0, r5);	 Catch:{ all -> 0x013c }
        r0 = "net_lib";
        r6.put(r0, r15);	 Catch:{ all -> 0x013c }
        r0 = "status_code";
        r6.put(r0, r13);	 Catch:{ all -> 0x013c }
        if (r14 == 0) goto L_0x00c6;
    L_0x00b3:
        r0 = r1.r;	 Catch:{ all -> 0x013c }
        r4 = "exception_msg_length";
        r5 = 500; // 0x1f4 float:7.0E-43 double:2.47E-321;
        r0 = r0.b(r4, r5);	 Catch:{ all -> 0x013c }
        r4 = "err_msg";
        r0 = c.j.a.d.b.n.a.f(r14, r0);	 Catch:{ all -> 0x013c }
        r6.put(r4, r0);	 Catch:{ all -> 0x013c }
    L_0x00c6:
        r0 = "download_sec";
        r6.put(r0, r9);	 Catch:{ all -> 0x013c }
        r0 = "download_mb";
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r4 = 0;
        r0 = (r9 > r4 ? 1 : (r9 == r4 ? 0 : -1));
        if (r0 <= 0) goto L_0x00dc;
    L_0x00d6:
        r0 = "download_speed";
        r2 = r2 / r9;
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
    L_0x00dc:
        r0 = "rw_concurrent";
        r2 = r1.x;	 Catch:{ all -> 0x013c }
        if (r2 == 0) goto L_0x00e4;
    L_0x00e2:
        r2 = 1;
        goto L_0x00e5;
    L_0x00e4:
        r2 = 0;
    L_0x00e5:
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r0 = r1.w;	 Catch:{ all -> 0x013c }
        if (r0 == 0) goto L_0x010a;
    L_0x00ec:
        r0 = "rw_read_time";
        r2 = r1.y;	 Catch:{ all -> 0x013c }
        r2 = (double) r2;	 Catch:{ all -> 0x013c }
        r2 = r2 / r17;
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r0 = "rw_write_time";
        r2 = r1.z;	 Catch:{ all -> 0x013c }
        r2 = (double) r2;	 Catch:{ all -> 0x013c }
        r2 = r2 / r17;
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r0 = "rw_sync_time";
        r2 = r1.A;	 Catch:{ all -> 0x013c }
        r2 = (double) r2;	 Catch:{ all -> 0x013c }
        r2 = r2 / r17;
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
    L_0x010a:
        r0 = "pkg_name";
        r2 = r1.a;	 Catch:{ all -> 0x013c }
        r2 = r2.w;	 Catch:{ all -> 0x013c }
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r0 = "name";
        r2 = r1.a;	 Catch:{ all -> 0x013c }
        r2 = r2.j0();	 Catch:{ all -> 0x013c }
        r6.put(r0, r2);	 Catch:{ all -> 0x013c }
        r0 = 3;
        r2 = r16;
        r3 = 1;
        if (r2 == r3) goto L_0x0129;
    L_0x0124:
        if (r2 != r0) goto L_0x0127;
    L_0x0126:
        goto L_0x0129;
    L_0x0127:
        r3 = 2;
        goto L_0x012c;
    L_0x0129:
        r3 = c.j.a.d.b.e.b.a;	 Catch:{ all -> 0x013c }
        goto L_0x0127;
    L_0x012c:
        if (r2 == r3) goto L_0x0130;
    L_0x012e:
        if (r2 != r0) goto L_0x0140;
    L_0x0130:
        r0 = c.j.a.d.b.e.b.Q;	 Catch:{ all -> 0x013c }
        if (r0 == 0) goto L_0x0140;
    L_0x0134:
        r2 = r1.a;	 Catch:{ all -> 0x013c }
        r3 = "download_io";
        r0.a(r2, r3, r6);	 Catch:{ all -> 0x013c }
        goto L_0x0140;
    L_0x013c:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0140:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.e.f.b(double):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:45:0x00b9  */
    public final void c(c.j.a.d.b.e.n r17) {
        /*
        r16 = this;
        r0 = r16;
        r7 = r17;
        if (r7 != 0) goto L_0x0007;
    L_0x0006:
        return;
    L_0x0007:
        r1 = 0;
        r8 = r7 instanceof c.j.a.d.b.c.e;
        if (r8 == 0) goto L_0x0017;
    L_0x000c:
        r1 = c.j.a.d.b.n.a.E();
        r1 = c.j.a.d.b.j.q.a(r1);
        if (r1 != 0) goto L_0x0017;
    L_0x0016:
        return;
    L_0x0017:
        r15 = r1;
        r1 = r0.c;
        r1 = r1.h();
        if (r1 == 0) goto L_0x0027;
    L_0x0020:
        r1 = r0.c;
        r1 = r1.i();
        goto L_0x0029;
    L_0x0027:
        r1 = r0.c;
    L_0x0029:
        r5 = r1;
        if (r5 == 0) goto L_0x00d5;
    L_0x002c:
        r1 = r0.m;
        r5.f(r1);
        if (r8 == 0) goto L_0x0045;
    L_0x0033:
        if (r15 == 0) goto L_0x0045;
    L_0x0035:
        r10 = r5.a;
        r11 = r5.f;
        r12 = r5.e();
        r13 = r0.m;
        r9 = r15;
        r9.m(r10, r11, r12, r13);
        r11 = r5;
        goto L_0x0056;
    L_0x0045:
        r2 = r5.a;
        r3 = r5.f;
        r4 = r5.e();
        r9 = r0.m;
        r1 = r17;
        r11 = r5;
        r5 = r9;
        r1.m(r2, r3, r4, r5);
    L_0x0056:
        r1 = r11.l();
        if (r1 == 0) goto L_0x00f8;
    L_0x005c:
        r1 = r11.m();
        r2 = 1;
        r3 = 0;
        if (r1 == 0) goto L_0x00b6;
    L_0x0064:
        r1 = r11.j;
        r4 = -1;
        if (r1 == 0) goto L_0x0098;
    L_0x006a:
        r1 = r1.i;
        if (r1 != 0) goto L_0x006f;
    L_0x006e:
        goto L_0x0098;
    L_0x006f:
        r1 = r1.indexOf(r11);
        r6 = 0;
        r9 = 0;
    L_0x0075:
        r10 = r11.j;
        r10 = r10.i;
        r10 = r10.size();
        if (r6 >= r10) goto L_0x0098;
    L_0x007f:
        r10 = r11.j;
        r10 = r10.i;
        r10 = r10.get(r6);
        r10 = (com.ss.android.socialbase.downloader.g.b) r10;
        if (r10 == 0) goto L_0x0095;
    L_0x008b:
        if (r9 == 0) goto L_0x0092;
    L_0x008d:
        r4 = r10.q();
        goto L_0x0098;
    L_0x0092:
        if (r1 != r6) goto L_0x0095;
    L_0x0094:
        r9 = 1;
    L_0x0095:
        r6 = r6 + 1;
        goto L_0x0075;
    L_0x0098:
        r9 = r0.m;
        r1 = (r4 > r9 ? 1 : (r4 == r9 ? 0 : -1));
        if (r1 <= 0) goto L_0x00b6;
    L_0x009e:
        if (r8 == 0) goto L_0x00ac;
    L_0x00a0:
        if (r15 == 0) goto L_0x00ac;
    L_0x00a2:
        r1 = r11.a;
        r3 = r11.e();
        r15.k(r1, r3, r4);
        goto L_0x00b7;
    L_0x00ac:
        r1 = r11.a;
        r3 = r11.e();
        r7.k(r1, r3, r4);
        goto L_0x00b7;
    L_0x00b6:
        r2 = 0;
    L_0x00b7:
        if (r2 != 0) goto L_0x00f8;
    L_0x00b9:
        if (r8 == 0) goto L_0x00c9;
    L_0x00bb:
        if (r15 == 0) goto L_0x00c9;
    L_0x00bd:
        r1 = r11.a;
        r2 = r11.e();
        r3 = r0.m;
        r15.k(r1, r2, r3);
        goto L_0x00f8;
    L_0x00c9:
        r1 = r11.a;
        r2 = r11.e();
        r3 = r0.m;
        r7.k(r1, r2, r3);
        goto L_0x00f8;
    L_0x00d5:
        r1 = r0.c;
        r1 = r1.h();
        if (r1 == 0) goto L_0x00f8;
    L_0x00dd:
        if (r8 == 0) goto L_0x00ed;
    L_0x00df:
        if (r15 == 0) goto L_0x00ed;
    L_0x00e1:
        r1 = r0.c;
        r2 = r1.a;
        r1 = r1.f;
        r3 = r0.m;
        r15.k(r2, r1, r3);
        goto L_0x00f8;
    L_0x00ed:
        r1 = r0.c;
        r2 = r1.a;
        r1 = r1.f;
        r3 = r0.m;
        r7.k(r2, r1, r3);
    L_0x00f8:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.e.f.c(c.j.a.d.b.e.n):void");
    }

    public final void d(boolean z) {
        long uptimeMillis = SystemClock.uptimeMillis();
        long j = uptimeMillis - this.D;
        if (this.t) {
            if (j > (this.s.c() ? this.u : this.v)) {
                i();
                this.D = uptimeMillis;
                return;
            }
            return;
        }
        long j2 = this.m - this.C;
        if (!z) {
            Object obj = (j2 <= 65536 || j <= 500) ? null : 1;
            if (obj == null) {
                return;
            }
        }
        i();
        this.D = uptimeMillis;
    }

    public void e() {
        if (!this.j) {
            this.j = true;
            if (this.d != null) {
                ExecutorService q = b.q();
                if (q != null) {
                    q.execute(new e(this));
                }
            }
        }
    }

    public void f() {
        if (!this.k) {
            synchronized (this.l) {
                this.k = true;
            }
            if (this.d != null) {
                ExecutorService q = b.q();
                if (q != null) {
                    q.execute(new e(this));
                }
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:259:0x03d3 A:{Catch:{ all -> 0x03d9 }} */
    /* JADX WARNING: Removed duplicated region for block: B:171:0x02b8 A:{SYNTHETIC, Splitter:B:171:0x02b8} */
    /* JADX WARNING: Removed duplicated region for block: B:204:0x0329 A:{SYNTHETIC, Splitter:B:204:0x0329} */
    /* JADX WARNING: Removed duplicated region for block: B:175:0x02db  */
    /* JADX WARNING: Removed duplicated region for block: B:222:0x0366 A:{Catch:{ all -> 0x03d9 }} */
    /* JADX WARNING: Removed duplicated region for block: B:259:0x03d3 A:{Catch:{ all -> 0x03d9 }} */
    /* JADX WARNING: Removed duplicated region for block: B:155:0x028b A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:7:0x0028} */
    /* JADX WARNING: Removed duplicated region for block: B:222:0x0366 A:{Catch:{ all -> 0x03d9 }} */
    /* JADX WARNING: Removed duplicated region for block: B:259:0x03d3 A:{Catch:{ all -> 0x03d9 }} */
    /* JADX WARNING: Removed duplicated region for block: B:171:0x02b8 A:{SYNTHETIC, Splitter:B:171:0x02b8} */
    /* JADX WARNING: Removed duplicated region for block: B:175:0x02db  */
    /* JADX WARNING: Removed duplicated region for block: B:204:0x0329 A:{SYNTHETIC, Splitter:B:204:0x0329} */
    /* JADX WARNING: Removed duplicated region for block: B:171:0x02b8 A:{SYNTHETIC, Splitter:B:171:0x02b8} */
    /* JADX WARNING: Removed duplicated region for block: B:204:0x0329 A:{SYNTHETIC, Splitter:B:204:0x0329} */
    /* JADX WARNING: Removed duplicated region for block: B:175:0x02db  */
    /* JADX WARNING: Removed duplicated region for block: B:266:0x03df  */
    /* JADX WARNING: Removed duplicated region for block: B:268:0x03e4  */
    /* JADX WARNING: Removed duplicated region for block: B:286:0x0403 A:{Catch:{ all -> 0x042f }} */
    /* JADX WARNING: Removed duplicated region for block: B:272:0x03eb A:{Catch:{ all -> 0x042f }} */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:155:0x028b, code skipped:
            r0 = th;
     */
    /* JADX WARNING: Missing block: B:156:0x028c, code skipped:
            r21 = r8;
     */
    /* JADX WARNING: Missing block: B:217:0x0340, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:218:0x0341, code skipped:
            r21 = r8;
            r13 = null;
     */
    public void g() throws com.ss.android.socialbase.downloader.e.a {
        /*
        r23 = this;
        r1 = r23;
        r0 = r23.h();
        if (r0 != 0) goto L_0x0446;
    L_0x0008:
        r0 = r1.c;
        if (r0 != 0) goto L_0x000e;
    L_0x000c:
        goto L_0x0446;
    L_0x000e:
        r0 = r1.d;
        r2 = c.j.a.d.b.n.a.b(r0);
        r4 = 0;
        r0 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r0 == 0) goto L_0x043c;
    L_0x001a:
        r0 = r1.c;
        r6 = r0.b;
        r8 = java.lang.System.nanoTime();
        r0 = r1.w;
        r10 = r1.d;
        r10 = r10 instanceof c.j.a.d.b.i.b;
        r13 = r1.a;	 Catch:{ a -> 0x0340, all -> 0x028b }
        r13 = r13.k0();	 Catch:{ a -> 0x028f, all -> 0x028b }
        r11 = r1.a;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r11 = r11.l0();	 Catch:{ a -> 0x028f, all -> 0x028b }
        r12 = r1.r;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r15 = "flush_buffer_size_byte";
        r14 = -1;
        r12 = r12.b(r15, r14);	 Catch:{ a -> 0x028f, all -> 0x028b }
        r11 = c.j.a.d.b.n.a.d(r13, r11, r12);	 Catch:{ a -> 0x028f, all -> 0x028b }
        r1.h = r11;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r12 = r1.m;	 Catch:{ IOException -> 0x02a4 }
        r11 = r11.c;	 Catch:{ IOException -> 0x02a4 }
        r11.seek(r12);	 Catch:{ IOException -> 0x02a4 }
        r11 = r1.d;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r11 = r11.a();	 Catch:{ a -> 0x028f, all -> 0x028b }
        if (r11 == 0) goto L_0x0293;
    L_0x0052:
        r12 = r1.a;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r14 = r12.d0;	 Catch:{ a -> 0x028f, all -> 0x028b }
        r16 = (r14 > r4 ? 1 : (r14 == r4 ? 0 : -1));
        if (r16 != 0) goto L_0x0060;
    L_0x005a:
        r14 = java.lang.System.nanoTime();	 Catch:{ a -> 0x028f, all -> 0x028b }
        r12.d0 = r14;	 Catch:{ a -> 0x028f, all -> 0x028b }
    L_0x0060:
        r11 = r1.a(r11);	 Catch:{ a -> 0x028f, all -> 0x028b }
        r12 = r1.a;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r14 = r1.x;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r14 = java.lang.Integer.valueOf(r14);	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r15 = "rw_concurrent";
        r12.t(r15, r14);	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r14 = r4;
    L_0x0072:
        r12 = r23.h();	 Catch:{ a -> 0x0285, all -> 0x0281 }
        if (r12 == 0) goto L_0x00d2;
    L_0x0078:
        r0 = r1.d;
        if (r0 == 0) goto L_0x007f;
    L_0x007c:
        r0.d();
    L_0x007f:
        r11.b();
        r0 = r1.q;	 Catch:{ all -> 0x00c5 }
        if (r0 == 0) goto L_0x009e;
    L_0x0086:
        r2 = r1.l;	 Catch:{ all -> 0x00c5 }
        monitor-enter(r2);	 Catch:{ all -> 0x00c5 }
        r0 = r1.k;	 Catch:{ all -> 0x009b }
        if (r0 != 0) goto L_0x0099;
    L_0x008d:
        r0 = r1.f;	 Catch:{ all -> 0x009b }
        r1.c(r0);	 Catch:{ all -> 0x009b }
        r0 = r1.h;	 Catch:{ all -> 0x009b }
        if (r0 == 0) goto L_0x0099;
    L_0x0096:
        r23.i();	 Catch:{ all -> 0x009b }
    L_0x0099:
        monitor-exit(r2);	 Catch:{ all -> 0x009b }
        goto L_0x00aa;
    L_0x009b:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x009b }
        throw r0;	 Catch:{ all -> 0x00c5 }
    L_0x009e:
        r0 = r1.f;	 Catch:{ all -> 0x00c5 }
        r1.c(r0);	 Catch:{ all -> 0x00c5 }
        r0 = r1.h;	 Catch:{ all -> 0x00c5 }
        if (r0 == 0) goto L_0x00aa;
    L_0x00a7:
        r23.i();	 Catch:{ all -> 0x00c5 }
    L_0x00aa:
        r2 = 1;
        r0 = new java.io.Closeable[r2];
        r2 = r1.h;
        r3 = 0;
        r0[r3] = r2;
        c.j.a.d.b.n.a.q(r0);
        r2 = r1.m;
        r4 = r1.n;
        r2 = r2 - r4;
        r2 = (double) r2;
        r4 = 4697254411347427328; // 0x4130000000000000 float:0.0 double:1048576.0;
        r2 = r2 / r4;
        r4 = java.lang.System.nanoTime();
        r4 = r4 - r8;
        goto L_0x03ba;
    L_0x00c5:
        r0 = move-exception;
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        throw r0;
    L_0x00d2:
        if (r0 == 0) goto L_0x00d8;
    L_0x00d4:
        r14 = java.lang.System.nanoTime();	 Catch:{ a -> 0x0285, all -> 0x0281 }
    L_0x00d8:
        r12 = r11.a();	 Catch:{ a -> 0x0285, all -> 0x0281 }
        if (r0 == 0) goto L_0x00ea;
    L_0x00de:
        r4 = r1.y;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r17 = java.lang.System.nanoTime();	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r17 = r17 - r14;
        r4 = r17 + r4;
        r1.y = r4;	 Catch:{ a -> 0x0285, all -> 0x0281 }
    L_0x00ea:
        r4 = r12.b;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r5 = -1;
        if (r4 != r5) goto L_0x00f5;
    L_0x00ef:
        r17 = r6;
        r21 = r8;
        goto L_0x019f;
    L_0x00f5:
        r13 = r1.a;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        java.util.Objects.requireNonNull(r13);	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r17 = r6;
        r5 = r1.p;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r19 = r14;
        r13 = r1.m;	 Catch:{ a -> 0x0285, all -> 0x0281 }
        r21 = r8;
        r7 = r1.n;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r13 = r13 - r7;
        r7 = (r5 > r13 ? 1 : (r5 == r13 ? 0 : -1));
        if (r7 <= 0) goto L_0x0121;
    L_0x010b:
        r5 = r1.p;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = r1.m;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r13 = r1.n;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = r7 - r13;
        r13 = (long) r4;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = r7 + r13;
        r13 = (r5 > r7 ? 1 : (r5 == r7 ? 0 : -1));
        if (r13 >= 0) goto L_0x0121;
    L_0x0118:
        r4 = r1.p;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = r1.m;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r13 = r1.n;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = r6 - r13;
        r4 = r4 - r6;
        r4 = (int) r4;	 Catch:{ a -> 0x027f, all -> 0x027d }
    L_0x0121:
        if (r0 == 0) goto L_0x0129;
    L_0x0123:
        r5 = java.lang.System.nanoTime();	 Catch:{ a -> 0x027f, all -> 0x027d }
        r14 = r5;
        goto L_0x012b;
    L_0x0129:
        r14 = r19;
    L_0x012b:
        r5 = r1.h;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = r12.a;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r5 = r5.a;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = 0;
        r5.write(r6, r7, r4);	 Catch:{ a -> 0x027f, all -> 0x027d }
        if (r0 == 0) goto L_0x0141;
    L_0x0137:
        r5 = r1.z;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = java.lang.System.nanoTime();	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = r7 - r14;
        r7 = r7 + r5;
        r1.z = r7;	 Catch:{ a -> 0x027f, all -> 0x027d }
    L_0x0141:
        r11.a(r12);	 Catch:{ a -> 0x027f, all -> 0x027d }
        r5 = r1.m;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r7 = (long) r4;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r5 = r5 + r7;
        r1.m = r5;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r4 = r1.l;	 Catch:{ a -> 0x027f, all -> 0x027d }
        monitor-enter(r4);	 Catch:{ a -> 0x027f, all -> 0x027d }
        r5 = r1.q;	 Catch:{ all -> 0x027a }
        if (r5 == 0) goto L_0x0166;
    L_0x0151:
        r5 = r1.k;	 Catch:{ all -> 0x027a }
        if (r5 != 0) goto L_0x0176;
    L_0x0155:
        r5 = r1.l;	 Catch:{ all -> 0x027a }
        r5 = (c.j.a.d.b.m.c) r5;
        r5 = r5.z(r7);	 Catch:{ all -> 0x027a }
        r6 = r1.f;	 Catch:{ all -> 0x027a }
        r1.c(r6);	 Catch:{ all -> 0x027a }
        r1.d(r5);	 Catch:{ all -> 0x027a }
        goto L_0x0176;
    L_0x0166:
        r5 = r1.l;	 Catch:{ all -> 0x027a }
        r5 = (c.j.a.d.b.m.c) r5;
        r5 = r5.z(r7);	 Catch:{ all -> 0x027a }
        r6 = r1.f;	 Catch:{ all -> 0x027a }
        r1.c(r6);	 Catch:{ all -> 0x027a }
        r1.d(r5);	 Catch:{ all -> 0x027a }
    L_0x0176:
        monitor-exit(r4);	 Catch:{ all -> 0x027a }
        r4 = r1.a;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r4 = r4.B();	 Catch:{ a -> 0x027f, all -> 0x027d }
        if (r4 == 0) goto L_0x0274;
    L_0x017f:
        r4 = r1.a;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r4 = r4.C();	 Catch:{ a -> 0x027f, all -> 0x027d }
        if (r4 == 0) goto L_0x026e;
    L_0x0187:
        r4 = r1.a;	 Catch:{ a -> 0x027f, all -> 0x027d }
        java.util.Objects.requireNonNull(r4);	 Catch:{ a -> 0x027f, all -> 0x027d }
        r4 = r1.p;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = 0;
        r8 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r8 < 0) goto L_0x0265;
    L_0x0194:
        r4 = r1.p;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = r1.m;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r12 = r1.n;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r6 = r6 - r12;
        r8 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r8 > 0) goto L_0x0265;
    L_0x019f:
        r0 = r1.d;
        if (r0 == 0) goto L_0x01a6;
    L_0x01a3:
        r0.d();
    L_0x01a6:
        r11.b();
        r0 = r1.q;	 Catch:{ all -> 0x0258 }
        if (r0 == 0) goto L_0x01c5;
    L_0x01ad:
        r4 = r1.l;	 Catch:{ all -> 0x0258 }
        monitor-enter(r4);	 Catch:{ all -> 0x0258 }
        r0 = r1.k;	 Catch:{ all -> 0x01c2 }
        if (r0 != 0) goto L_0x01c0;
    L_0x01b4:
        r0 = r1.f;	 Catch:{ all -> 0x01c2 }
        r1.c(r0);	 Catch:{ all -> 0x01c2 }
        r0 = r1.h;	 Catch:{ all -> 0x01c2 }
        if (r0 == 0) goto L_0x01c0;
    L_0x01bd:
        r23.i();	 Catch:{ all -> 0x01c2 }
    L_0x01c0:
        monitor-exit(r4);	 Catch:{ all -> 0x01c2 }
        goto L_0x01d1;
    L_0x01c2:
        r0 = move-exception;
        monitor-exit(r4);	 Catch:{ all -> 0x01c2 }
        throw r0;	 Catch:{ all -> 0x0258 }
    L_0x01c5:
        r0 = r1.f;	 Catch:{ all -> 0x0258 }
        r1.c(r0);	 Catch:{ all -> 0x0258 }
        r0 = r1.h;	 Catch:{ all -> 0x0258 }
        if (r0 == 0) goto L_0x01d1;
    L_0x01ce:
        r23.i();	 Catch:{ all -> 0x0258 }
    L_0x01d1:
        r4 = 1;
        r0 = new java.io.Closeable[r4];
        r4 = r1.h;
        r5 = 0;
        r0[r5] = r4;
        c.j.a.d.b.n.a.q(r0);
        r4 = r1.m;
        r6 = r1.n;
        r4 = r4 - r6;
        r4 = (double) r4;
        r6 = 4697254411347427328; // 0x4130000000000000 float:0.0 double:1048576.0;
        r4 = r4 / r6;
        r6 = java.lang.System.nanoTime();
        r6 = r6 - r21;
        r1.B = r6;
        r1.b(r4);
        r0 = r1.a;
        java.util.Objects.requireNonNull(r0);
        r4 = r1.m;
        r6 = r1.n;
        r4 = r4 - r6;
        r6 = 0;
        r0 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r0 < 0) goto L_0x0257;
    L_0x0200:
        r8 = r1.p;
        r0 = (r8 > r6 ? 1 : (r8 == r6 ? 0 : -1));
        if (r0 < 0) goto L_0x0257;
    L_0x0206:
        r6 = r1.p;
        r0 = (r6 > r4 ? 1 : (r6 == r4 ? 0 : -1));
        if (r0 != 0) goto L_0x020d;
    L_0x020c:
        goto L_0x0257;
    L_0x020d:
        r0 = new com.ss.android.socialbase.downloader.e.a;
        r6 = 1051; // 0x41b float:1.473E-42 double:5.193E-321;
        r7 = "handle data length[%d] != content length[%d] downloadChunkContentLen[%d], range[%d, %d) , current offset[%d] , handle start from %d";
        r8 = 7;
        r8 = new java.lang.Object[r8];
        r4 = java.lang.Long.valueOf(r4);
        r5 = 0;
        r8[r5] = r4;
        r2 = java.lang.Long.valueOf(r2);
        r3 = 1;
        r8[r3] = r2;
        r2 = 2;
        r3 = r1.p;
        r3 = java.lang.Long.valueOf(r3);
        r8[r2] = r3;
        r2 = 3;
        r3 = java.lang.Long.valueOf(r17);
        r8[r2] = r3;
        r2 = 4;
        r3 = r1.o;
        r3 = java.lang.Long.valueOf(r3);
        r8[r2] = r3;
        r2 = 5;
        r3 = r1.m;
        r3 = java.lang.Long.valueOf(r3);
        r8[r2] = r3;
        r2 = 6;
        r3 = r1.n;
        r3 = java.lang.Long.valueOf(r3);
        r8[r2] = r3;
        r2 = java.lang.String.format(r7, r8);
        r0.m4677init(r6, r2);
        throw r0;
    L_0x0257:
        return;
    L_0x0258:
        r0 = move-exception;
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        throw r0;
    L_0x0265:
        r6 = 0;
        r4 = r6;
        r6 = r17;
        r8 = r21;
        goto L_0x0072;
    L_0x026e:
        r0 = new com.ss.android.socialbase.downloader.e.f;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r0.m8394init();	 Catch:{ a -> 0x027f, all -> 0x027d }
        throw r0;	 Catch:{ a -> 0x027f, all -> 0x027d }
    L_0x0274:
        r0 = new com.ss.android.socialbase.downloader.e.d;	 Catch:{ a -> 0x027f, all -> 0x027d }
        r0.m8393init();	 Catch:{ a -> 0x027f, all -> 0x027d }
        throw r0;	 Catch:{ a -> 0x027f, all -> 0x027d }
    L_0x027a:
        r0 = move-exception;
        monitor-exit(r4);	 Catch:{ all -> 0x027a }
        throw r0;	 Catch:{ a -> 0x027f, all -> 0x027d }
    L_0x027d:
        r0 = move-exception;
        goto L_0x02b6;
    L_0x027f:
        r0 = move-exception;
        goto L_0x0288;
    L_0x0281:
        r0 = move-exception;
        r21 = r8;
        goto L_0x02b6;
    L_0x0285:
        r0 = move-exception;
        r21 = r8;
    L_0x0288:
        r13 = r11;
        goto L_0x0345;
    L_0x028b:
        r0 = move-exception;
        r21 = r8;
        goto L_0x02b5;
    L_0x028f:
        r0 = move-exception;
        r21 = r8;
        goto L_0x02b2;
    L_0x0293:
        r21 = r8;
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x02b1, all -> 0x02af }
        r2 = 1042; // 0x412 float:1.46E-42 double:5.15E-321;
        r3 = new java.io.IOException;	 Catch:{ a -> 0x02b1, all -> 0x02af }
        r4 = "inputStream is null";
        r3.<init>(r4);	 Catch:{ a -> 0x02b1, all -> 0x02af }
        r0.m4678init(r2, r3);	 Catch:{ a -> 0x02b1, all -> 0x02af }
        throw r0;	 Catch:{ a -> 0x02b1, all -> 0x02af }
    L_0x02a4:
        r0 = move-exception;
        r21 = r8;
        r2 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x02b1, all -> 0x02af }
        r3 = 1054; // 0x41e float:1.477E-42 double:5.207E-321;
        r2.m4678init(r3, r0);	 Catch:{ a -> 0x02b1, all -> 0x02af }
        throw r2;	 Catch:{ a -> 0x02b1, all -> 0x02af }
    L_0x02af:
        r0 = move-exception;
        goto L_0x02b5;
    L_0x02b1:
        r0 = move-exception;
    L_0x02b2:
        r13 = 0;
        goto L_0x0345;
    L_0x02b5:
        r11 = 0;
    L_0x02b6:
        if (r10 == 0) goto L_0x02bf;
    L_0x02b8:
        r2 = r1.d;	 Catch:{ all -> 0x033d }
        r2 = (c.j.a.d.b.i.b) r2;	 Catch:{ all -> 0x033d }
        java.util.Objects.requireNonNull(r2);	 Catch:{ all -> 0x033d }
    L_0x02bf:
        r2 = "ResponseHandler";
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x033d }
        r3.<init>();	 Catch:{ all -> 0x033d }
        r4 = "handleResponse: e = ";
        r3.append(r4);	 Catch:{ all -> 0x033d }
        r3.append(r0);	 Catch:{ all -> 0x033d }
        r3 = r3.toString();	 Catch:{ all -> 0x033d }
        c.j.a.d.b.g.a.f(r2, r3);	 Catch:{ all -> 0x033d }
        r2 = r23.h();	 Catch:{ all -> 0x033d }
        if (r2 == 0) goto L_0x0329;
    L_0x02db:
        r0 = r1.d;
        if (r0 == 0) goto L_0x02e2;
    L_0x02df:
        r0.d();
    L_0x02e2:
        if (r11 == 0) goto L_0x02e7;
    L_0x02e4:
        r11.b();
    L_0x02e7:
        r0 = r1.q;	 Catch:{ all -> 0x031c }
        if (r0 == 0) goto L_0x0303;
    L_0x02eb:
        r2 = r1.l;	 Catch:{ all -> 0x031c }
        monitor-enter(r2);	 Catch:{ all -> 0x031c }
        r0 = r1.k;	 Catch:{ all -> 0x0300 }
        if (r0 != 0) goto L_0x02fe;
    L_0x02f2:
        r0 = r1.f;	 Catch:{ all -> 0x0300 }
        r1.c(r0);	 Catch:{ all -> 0x0300 }
        r0 = r1.h;	 Catch:{ all -> 0x0300 }
        if (r0 == 0) goto L_0x02fe;
    L_0x02fb:
        r23.i();	 Catch:{ all -> 0x0300 }
    L_0x02fe:
        monitor-exit(r2);	 Catch:{ all -> 0x0300 }
        goto L_0x030f;
    L_0x0300:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x0300 }
        throw r0;	 Catch:{ all -> 0x031c }
    L_0x0303:
        r0 = r1.f;	 Catch:{ all -> 0x031c }
        r1.c(r0);	 Catch:{ all -> 0x031c }
        r0 = r1.h;	 Catch:{ all -> 0x031c }
        if (r0 == 0) goto L_0x030f;
    L_0x030c:
        r23.i();	 Catch:{ all -> 0x031c }
    L_0x030f:
        r2 = 1;
        r0 = new java.io.Closeable[r2];
        r2 = r1.h;
        r3 = 0;
        r0[r3] = r2;
        c.j.a.d.b.n.a.q(r0);
        goto L_0x03ab;
    L_0x031c:
        r0 = move-exception;
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        throw r0;
    L_0x0329:
        r2 = c.j.a.d.b.g.a.b();	 Catch:{ all -> 0x033d }
        if (r2 == 0) goto L_0x0332;
    L_0x032f:
        r0.printStackTrace();	 Catch:{ all -> 0x033d }
    L_0x0332:
        r2 = "ResponseHandler";
        c.j.a.d.b.n.a.o(r0, r2);	 Catch:{ a -> 0x0339 }
        r2 = 0;
        throw r2;
    L_0x0339:
        r0 = move-exception;
        r1.i = r0;	 Catch:{ all -> 0x033d }
        throw r0;	 Catch:{ all -> 0x033d }
    L_0x033d:
        r0 = move-exception;
        goto L_0x03db;
    L_0x0340:
        r0 = move-exception;
        r21 = r8;
        r2 = 0;
        r13 = r2;
    L_0x0345:
        r2 = "ResponseHandler";
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x03d9 }
        r3.<init>();	 Catch:{ all -> 0x03d9 }
        r4 = "handleResponse: BaseException e = ";
        r3.append(r4);	 Catch:{ all -> 0x03d9 }
        r3.append(r0);	 Catch:{ all -> 0x03d9 }
        r3 = r3.toString();	 Catch:{ all -> 0x03d9 }
        c.j.a.d.b.g.a.f(r2, r3);	 Catch:{ all -> 0x03d9 }
        r2 = r1.r;	 Catch:{ all -> 0x03d9 }
        r3 = "ignore_base_ex_on_stop_status";
        r4 = 0;
        r2 = r2.k(r3, r4);	 Catch:{ all -> 0x03d9 }
        if (r2 == 0) goto L_0x03cd;
    L_0x0366:
        r2 = r23.h();	 Catch:{ all -> 0x03d9 }
        if (r2 == 0) goto L_0x03cd;
    L_0x036c:
        r0 = r1.d;
        if (r0 == 0) goto L_0x0373;
    L_0x0370:
        r0.d();
    L_0x0373:
        if (r13 == 0) goto L_0x0378;
    L_0x0375:
        r13.b();
    L_0x0378:
        r0 = r1.q;	 Catch:{ all -> 0x03c0 }
        if (r0 == 0) goto L_0x0394;
    L_0x037c:
        r2 = r1.l;	 Catch:{ all -> 0x03c0 }
        monitor-enter(r2);	 Catch:{ all -> 0x03c0 }
        r0 = r1.k;	 Catch:{ all -> 0x0391 }
        if (r0 != 0) goto L_0x038f;
    L_0x0383:
        r0 = r1.f;	 Catch:{ all -> 0x0391 }
        r1.c(r0);	 Catch:{ all -> 0x0391 }
        r0 = r1.h;	 Catch:{ all -> 0x0391 }
        if (r0 == 0) goto L_0x038f;
    L_0x038c:
        r23.i();	 Catch:{ all -> 0x0391 }
    L_0x038f:
        monitor-exit(r2);	 Catch:{ all -> 0x0391 }
        goto L_0x03a0;
    L_0x0391:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x0391 }
        throw r0;	 Catch:{ all -> 0x03c0 }
    L_0x0394:
        r0 = r1.f;	 Catch:{ all -> 0x03c0 }
        r1.c(r0);	 Catch:{ all -> 0x03c0 }
        r0 = r1.h;	 Catch:{ all -> 0x03c0 }
        if (r0 == 0) goto L_0x03a0;
    L_0x039d:
        r23.i();	 Catch:{ all -> 0x03c0 }
    L_0x03a0:
        r2 = 1;
        r0 = new java.io.Closeable[r2];
        r2 = r1.h;
        r3 = 0;
        r0[r3] = r2;
        c.j.a.d.b.n.a.q(r0);
    L_0x03ab:
        r2 = r1.m;
        r4 = r1.n;
        r2 = r2 - r4;
        r2 = (double) r2;
        r4 = 4697254411347427328; // 0x4130000000000000 float:0.0 double:1048576.0;
        r2 = r2 / r4;
        r4 = java.lang.System.nanoTime();
        r4 = r4 - r21;
    L_0x03ba:
        r1.B = r4;
        r1.b(r2);
        return;
    L_0x03c0:
        r0 = move-exception;
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        throw r0;
    L_0x03cd:
        r2 = c.j.a.d.b.g.a.b();	 Catch:{ all -> 0x03d9 }
        if (r2 == 0) goto L_0x03d6;
    L_0x03d3:
        r0.printStackTrace();	 Catch:{ all -> 0x03d9 }
    L_0x03d6:
        r1.i = r0;	 Catch:{ all -> 0x03d9 }
        throw r0;	 Catch:{ all -> 0x03d9 }
    L_0x03d9:
        r0 = move-exception;
        r11 = r13;
    L_0x03db:
        r2 = r1.d;
        if (r2 == 0) goto L_0x03e2;
    L_0x03df:
        r2.d();
    L_0x03e2:
        if (r11 == 0) goto L_0x03e7;
    L_0x03e4:
        r11.b();
    L_0x03e7:
        r2 = r1.q;	 Catch:{ all -> 0x042f }
        if (r2 == 0) goto L_0x0403;
    L_0x03eb:
        r2 = r1.l;	 Catch:{ all -> 0x042f }
        monitor-enter(r2);	 Catch:{ all -> 0x042f }
        r3 = r1.k;	 Catch:{ all -> 0x0400 }
        if (r3 != 0) goto L_0x03fe;
    L_0x03f2:
        r3 = r1.f;	 Catch:{ all -> 0x0400 }
        r1.c(r3);	 Catch:{ all -> 0x0400 }
        r3 = r1.h;	 Catch:{ all -> 0x0400 }
        if (r3 == 0) goto L_0x03fe;
    L_0x03fb:
        r23.i();	 Catch:{ all -> 0x0400 }
    L_0x03fe:
        monitor-exit(r2);	 Catch:{ all -> 0x0400 }
        goto L_0x040f;
    L_0x0400:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x0400 }
        throw r0;	 Catch:{ all -> 0x042f }
    L_0x0403:
        r2 = r1.f;	 Catch:{ all -> 0x042f }
        r1.c(r2);	 Catch:{ all -> 0x042f }
        r2 = r1.h;	 Catch:{ all -> 0x042f }
        if (r2 == 0) goto L_0x040f;
    L_0x040c:
        r23.i();	 Catch:{ all -> 0x042f }
    L_0x040f:
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        r2 = r1.m;
        r4 = r1.n;
        r2 = r2 - r4;
        r2 = (double) r2;
        r4 = 4697254411347427328; // 0x4130000000000000 float:0.0 double:1048576.0;
        r2 = r2 / r4;
        r4 = java.lang.System.nanoTime();
        r4 = r4 - r21;
        r1.B = r4;
        r1.b(r2);
        throw r0;
    L_0x042f:
        r0 = move-exception;
        r2 = 1;
        r2 = new java.io.Closeable[r2];
        r3 = r1.h;
        r4 = 0;
        r2[r4] = r3;
        c.j.a.d.b.n.a.q(r2);
        throw r0;
    L_0x043c:
        r0 = new com.ss.android.socialbase.downloader.e.g;
        r2 = 1004; // 0x3ec float:1.407E-42 double:4.96E-321;
        r3 = "the content-length is 0";
        r0.m7698init(r2, r3);
        throw r0;
    L_0x0446:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.e.f.g():void");
    }

    public final boolean h() {
        return this.j || this.k;
    }

    public final void i() {
        Object obj;
        long nanoTime = this.w ? System.nanoTime() : 0;
        Object obj2 = null;
        try {
            d dVar = this.h;
            BufferedOutputStream bufferedOutputStream = dVar.a;
            if (bufferedOutputStream != null) {
                bufferedOutputStream.flush();
            }
            FileDescriptor fileDescriptor = dVar.b;
            if (fileDescriptor != null) {
                fileDescriptor.sync();
            }
            obj = 1;
        } catch (Exception unused) {
            obj = null;
        }
        if (obj != null) {
            this.a.f0(true);
            if (this.a.R > 1) {
                obj2 = 1;
            }
            p a = q.a(c.j.a.d.b.n.a.E());
            if (obj2 != null) {
                c(this.g);
                if (a != null) {
                    a.c(this.a);
                } else {
                    this.g.a(this.a.g0(), this.a.I());
                }
            } else if (a != null) {
                a.c(this.a);
            } else {
                this.g.a(this.c.a, this.m);
            }
            this.C = this.m;
        }
        if (this.w) {
            this.A += System.nanoTime() - nanoTime;
        }
    }
}
